﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace CDSBDemandControl.Model
{
    [Serializable]
    public class DeveloperModel
    {
        #region Construtores

        public DeveloperModel() { }

        public DeveloperModel(string developerName, string developerTeam, Mission mission)
        {
            this.DeveloperName = developerName;
            this.DeveloperTeam = developerTeam;
            this.Mission = mission;
        }

        public DeveloperModel(string name, string team, Mission mission, DateTime? startFreeDaysPaid, DateTime? finishFreeDaysPaid, string remarks, Int32 vh, List<string> responsibleFor, int tasksImplemented, int tasksReleasedLate)
        {
            this.DeveloperName = name;
            this.Mission = mission;
            this.DeveloperTeam = team;
            this.StartFreeDaysPaid = startFreeDaysPaid;
            this.FinishFreeDaysPaid = finishFreeDaysPaid;
            this.Remarks = remarks;
            this.VH = vh;
            this.ResponsibleFor = responsibleFor;
            this.TasksImplemented = tasksImplemented;
            this.TasksReleasedLate = tasksReleasedLate;
        }

        #endregion

        #region Propriedades Configuraveis

        public string DeveloperName { get; set; }
        public string DeveloperADUserName { get; set; }
        public string DeveloperTeam { get; set; }
        public bool IsActive { get; set; }
        public Mission Mission { get; set; }
        public DateTime? StartFreeDaysPaid { get; set; }
        public DateTime? FinishFreeDaysPaid { get; set; }
        public DateTime? DeveloperStartAt { get; set; }

        public List<string> Dayof { get; set; }
        public List<string> ResponsibleFor { get; set; }

        public string Remarks { get; set; }
        public int VH { get; set; }
        
        #endregion

        #region Propriedades Calculadas

        
        public string StatusColor { get; set; }
        public int TasksImplemented { get; set; }
        public int TasksReleasedLate { get; set; }
        public int TasksDisapprovedInCodeReview { get; set; }
        public int DayPast { get; set; }

        private Decimal _percentDelays;
        public Decimal PercentDelays
        {
            get
            {
                if (TasksImplemented > 0)
                {
                    return Decimal.Round((100 * TasksReleasedLate) / TasksImplemented, 0);
                }
                else
                {
                    return 0;
                }
            }
            set { _percentDelays = value; }
        }

        private Decimal _averageDayPast;
        public Decimal AverageDayPast
        {
            get
            {
                if (TasksReleasedLate > 0)
                {
                    return DayPast / TasksReleasedLate;
                }
                else
                {
                    return 0;
                }
            }
            set { _averageDayPast = value; }
        }

        #endregion
    }
}
